<?php

declare(strict_types=1);

namespace Api\InterfaceApi\v1\Work;

use Api\Request\v1\Work\ExternalContactRequest;
use Api\Service\v1\Work\ExternalContactApiService;
use Hyperf\Di\Annotation\Inject;
use Mine\MineApi;

/**
 * 外部联系人
 */
class ExternalContactApi extends MineApi
{
    #[Inject]
    protected ExternalContactApiService $service;

    /**
     * 获取外部联系人列表
     * @param ExternalContactRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    public function getExternalContactList(ExternalContactRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->success($this->service->getExternalContactList($request->all()));
    }

    public function getExternalContactDetail(ExternalContactRequest $request)
    {
        return $this->success($this->service->getExternalContactDetail($request->all()));
    }

    /**
     * 批量获取外部联系人详情
     * @param ExternalContactRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    public function batchGetExternalContactDetail(ExternalContactRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->success($this->service->batchGetExternalContactDetail($request->all()));
    }

    /**
     * 获取客户群列表
     * @param ExternalContactRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    public function getExternalContactGroupChatList(ExternalContactRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->success($this->service->getExternalContactGroupChatList($request->all()));
    }

    /**
     * 获取客户群详情
     * @param ExternalContactRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    public function getExternalContactGroupChatDetail(ExternalContactRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->success($this->service->getExternalContactGroupChatDetail($request->all()));
    }

    /**
     * 修改客户信息
     * @param ExternalContactRequest $request
     * @return mixed
     */
    public function modifyExternalContactInfo(ExternalContactRequest $request): mixed
    {
        return $this->service->modifyExternalContactInfo($request->all()) ? $this->success() : $this->error();
    }

    public function markTag(ExternalContactRequest $request): mixed
    {
        return $this->service->markTag($request->all()) ? $this->success() : $this->error();
    }
}